package com.dgut.dao.impl;

import com.dgut.dao.HousingDao;
import com.dgut.model.Housing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author GooRay
 * 创建于 2020/6/21
 */
@Repository
public class HousingDaoImpl implements HousingDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public Housing findByUserID(Integer user_id){
        String sql = "select * from housing where user_id = ?";
        List<Housing> housings = jdbcTemplate.query(sql, new BeanPropertyRowMapper<Housing>(Housing.class), user_id);
        return housings.get(0);
    }
}
